#include<stdio.h>
#include<sys/types.h>
#include<string.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/wait.h>


void ChildRun()
{
  int cnt = 5;
  while(cnt)
  {
    printf("child running!,pid = %d,ppid = %d\n",getpid(),getppid());
    sleep(1);
    --cnt;
  }
}
int main()
{
  pid_t id = fork();
  if(id == 0)
  {
    //child
    ChildRun();
    exit(11);
  }
  //pid_t rid = wait(NULL);
  sleep(10);
  pid_t rid = waitpid(id+1,NULL,0);
  printf("child exit...\n");
  sleep(5);
  if(rid>0)
  {
    printf("wait success!,rid = %d\n",rid);
  }
  else 
  {
    printf("wait failed!\n");
  }
  return 0;
}
